<?php

return [
    'coroutine' => [
        'enable' => true,
        'flags' => SWOOLE_HOOK_ALL,
    ],
    'http'       => [
        'enable'     => true,
        'host'       => '0.0.0.0',
        'port'       => 3411,
        'worker_num' => swoole_cpu_num()*4,
        'options'    => [
            'daemonize' =>  true,
            'package_max_length' => 512 *1024*1024,//设置最大数据包尺寸，单位为字节。【默认值：2M 即 2 * 1024 * 1024，最小值为 64K】
        ]
    ],
    'websocket'  => [
        'enable'        => true,
        'route' => true,
        'handler'       => \think\swoole\websocket\Handler::class,
        'ping_interval' => 25000,
        'ping_timeout'  => 60000,
        'room'          => [
            'type'  => 'table',
            'table' => [
                'room_rows'   => 8192,
                'room_size'   => 2048,
                'client_rows' => 4096,
                'client_size' => 2048,
            ],
//            'redis' => [
//                'host'          => env('REDIS_HOST','127.0.0.1'),
//                'port'          => env('REDIS_PORT','6379'),
//                'password'      => env('REDIS_PASSWD','123456'),
//                'max_active'    => 100,
//                'max_wait_time' => 5,
//            ],
        ],
        'listen'        => [],
        'subscribe'     => [],
    ],
    'rpc'        => [
        'server' => [
            'enable'     => false,
            'host'       => '0.0.0.0',
            'port'       => 3412,
            'worker_num' => swoole_cpu_num()*4,
            'services'   => [],
        ],
        'client' => [],
    ],
    //队列
    'queue'      => [
        'enable'  => true,
        'workers' => [
            'CronJob' => [ // 队列标识
                'handler'  => app\job\CronJob::class, // 对应上面的处理类
                'count'    => swoole_cpu_num(), // 进程数
                'max_jobs' => 1000, // 单个进程最大处理任务数（超限重启）
                'memory'   => 512, // 进程内存限制（MB，超限重启）
                'tries'    => 3, // 任务失败重试次数
            ],
        ],
    ],
    'hot_update' => [
        'enable'  => env('APP_DEBUG', false),
        'name'    => ['*.php'],
        'include' => [app_path()],
        'exclude' => [],
    ],
    //连接池
    'pool'       => [
        'db'    => [
            'enable'        => true,
            'max_active'    => 100,
            'max_wait_time' => 5,
        ],
        'cache' => [
            'enable'        => true,
            'max_active'    => 100,
            'max_wait_time' => 5,
        ],
        //自定义连接池
    ],
    'ipc'        => [
        'type'  => 'unix_socket',
//        'redis' => [
//            'host'          => env('REDIS_HOST','127.0.0.1'),
//            'port'          => env('REDIS_PORT','6379'),
//            'password'      => env('REDIS_PASSWD','123456'),
//            'max_active'    => 100,
//            'max_wait_time' => 5,
//        ],
    ],
    //锁
    'lock'       => [
        'enable' => true,
        'type'   => 'table',
//        'redis'  => [
//            'host'          => env('REDIS_HOST','127.0.0.1'),
//            'port'          => env('REDIS_PORT','6379'),
//            'password'      => env('REDIS_PASSWD','123456'),
//            'max_active'    => 100,
//            'max_wait_time' => 5,
//        ],
    ],
    'tables'     => [],
    //每个worker里需要预加载以共用的实例
    'concretes'  => [],
    //重置器
    'resetters'  => [],
    //每次请求前需要清空的实例
    'instances'  => [],
    //每次请求前需要重新执行的服务
    'services'   => [],
];
